<template>
	<view>
		<view class="integral_bg"
			:style="'background:url('+imageSrc+') no-repeat;background-size: 100%;background-position: 0;'">
			<image class="head_img" :src="userInfo.handlUrl" mode=""></image>
			<view class="int_title u-border-bottom">
				积分:{{integral.integral}}分
			</view>
			<view class="" style="padding: 0 136rpx">
				<view class="int_type u-border-bottom">
					<view class="type_box ">
						<view class="title">
							使用积分
						</view>
						<view class="num_box">
							<image class="icon" src="../../static/img/jifen-icon.png" mode=""></image>
							<view class="num">
								{{integral.useIntegral}}分
							</view>

						</view>
					</view>
					<u-line color="#fff" direction='col' margin='0 50rpx' length='92rpx' />
					<view class="type_box">
						<view class="title">
							获得积分
						</view>
						<view class="num_box">
							<image class="icon" src="../../static/img/jifen-icon.png" mode=""></image>
							<view class="num">
								{{integral.gainIntegral}}分
							</view>

						</view>
					</view>
				</view>
			</view>
		</view>
		<u-gap height="14" bg-color="#ECECEC"></u-gap>
		<view class="int_detail_title u-border-bottom">
			<image class="icon" src="../../static/img/jifen-icon.png" mode=""></image>
			<view class="title">
				积分明细
			</view>
		</view>
		<u-empty v-if="list.length==0"></u-empty>
		<view class="int_list" v-else>
			<view class="item u-border-bottom" v-for="item in list" :key='item.id'>
				<view class="right u-border-right">
					<image class="icon" :src="item.imgUrl" mode="">
					</image>
					<view class="content">
						{{item.title}}
					</view>
				</view>
				<view class="num">
					{{item.type==1?'+':'-'}}{{item.quantity}}
				</view>
			</view>
			<u-loadmore :status="status" />
		</view>

	</view>
</template>

<script>
	import initData from '@/mixin/initData.js'
	export default {
		mixins: [initData],
		data() {
			return {
				imageSrc: '../../static/img/jifenbg.png',
				integral: {},
				userInfo: {},
				integralList: []
			};
		},
		onLoad() {
			const userInfo = this.cache.getCache('userInfo')
			if (userInfo) {

				this.userInfo = userInfo
			}
			this.myIntegralDetails()
			this.miXinInit()
		},
		methods: {
			// 请求前的参数处理
			beforeInit() {
				this.apiUrl = "appUser/myIntegralDetailsList";
				let params = {
					pageNum: this.pageNum,
					pageSize: this.pageSize,
				};

				this.params = {
					...params
				};
			},
			myIntegralDetails() {
				this.$u.api.myIntegralDetails().then(res => {
					this.integral = res
				})

			},
			init() {
				// myIntegralDetailsList,
				// myIntegralDetails,
			}
		}
	}
</script>

<style lang="scss" scoped>
	.int_list {
		padding: 0 30rpx;

		.item {
			padding: 24rpx 0;

			display: flex;
			align-items: center;
			justify-content: space-between;

			.right {
				display: flex;
				padding-right: 30rpx;
				margin-right: 30rpx;
				width: 80%;
			}

			.num {
				color: #FF0E3D;
				font-size: 32rpx;
				max-width: 20%;
				width: 20%;
			}

			.content {
				font-size: 21rpx;
				color: #ACACAC;
				@include ellipsisMultiline(2);

				// margin-right: 10rpx;
			}

			.icon {
				width: 54rpx;
				height: 54rpx;
				min-width: 54rpx;
				min-height: 54rpx;
				margin-right: 20rpx;
			}
		}
	}

	.int_detail_title {
		display: flex;
		padding: 20rpx;
		align-items: center;

		.title {
			font-size: #101010;
			font-size: 28rpx;
		}

		.icon {
			width: 40rpx;
			height: 40rpx;
			margin-right: 8rpx;

		}
	}

	.int_type {
		display: flex;
		align-items: center;
		justify-content: center;
		padding-bottom: 20rpx;

		.type_box {
			display: flex;
			flex-direction: column;
			align-items: center;

			.num_box {
				display: flex;
				align-items: center;

				.num {
					font-size: 30rpx;
					color: #fff;
				}

				.icon {
					width: 34rpx;
					height: 34rpx;
				}

			}

			.title {
				font-size: 26rpx;
				color: #fff;
				margin-bottom: 20rpx;
			}
		}
	}

	.integral_bg {
		position: relative;
		width: 700rpx;
		height: 326rpx;
		border-radius: 20rpx;
		margin: 0 auto;
		margin-bottom: 20rpx;
		margin-top: 90rpx;
		padding: 81rpx 0 20rpx 0;

		.int_title {
			text-align: center;
			font-size: 42rpx;
			color: #FFFFFF;
			font-weight: 600;
			padding-bottom: 25rpx;
			margin-bottom: 20rpx;
		}

		.head_img {
			width: 122rpx;
			height: 122rpx;
			border-radius: 50%;
			border: 4rpx solid #FDBB9E;
			position: absolute;
			top: -61rpx;
			left: 50%;
			margin-left: -61rpx;
			background-color: #fff;
		}
	}
</style>
